set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_SYSTEM_PROCESSOR $ENV{WIN_XCOMPILE_ARCH})
set(TOOLCHAIN_PREFIX $ENV{WIN_XCOMPILE_ARCH}-w64-mingw32)

#set(CMAKE_SYSROOT $ENV{WIN_XCOMPILE_ROOT}/win-rootfs/$ENV{WIN_XCOMPILE_ARCH}/usr)
#set(CMAKE_SYSTEM_PREFIX_PATH /)

set(CMAKE_C_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-gcc-posix)
set(CMAKE_CXX_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-g++-posix)
set(CMAKE_AR /usr/bin/${TOOLCHAIN_PREFIX}-ar)
set(CMAKE_C_COMPILER_AR /usr/bin/${TOOLCHAIN_PREFIX}-ar)
set(CMAKE_CXX_COMPILER_AR /usr/bin/${TOOLCHAIN_PREFIX}-ar)
set(CMAKE_RANLIB /usr/bin/${TOOLCHAIN_PREFIX}-ranlib)
set(CMAKE_C_COMPILER_RANLIB /usr/bin/${TOOLCHAIN_PREFIX}-ranlib)
set(CMAKE_CXX_COMPILER_RANLIB /usr/bin/${TOOLCHAIN_PREFIX}-ranlib)
set(CMAKE_LINKER /usr/bin/${TOOLCHAIN_PREFIX}-ld)

set(CMAKE_FIND_ROOT_PATH $ENV{WIN_XCOMPILE_ROOT}/$ENV{WIN_XCOMPILE_ARCH}/usr /usr/include)
message(STATUS "My Variable: ${CMAKE_FIND_ROOT_PATH}")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)

set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .dll .a CONFIG)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

set(BUILD_SHARED_LIBS ON)

add_definitions("-D__STDC_LIMIT_MACROS=1" "-D__STDC_FORMAT_MACROS=1" "-DNOMINMAX" "-DHMP_BUILD_SHARED")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:preprocessor /wd5105 /EHsc")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD /Zi")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd /DEBUG /Zi")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")

include_directories($ENV{WIN_XCOMPILE_ROOT}/$ENV{WIN_XCOMPILE_ARCH}/usr/include)
link_directories($ENV{WIN_XCOMPILE_ROOT}/$ENV{WIN_XCOMPILE_ARCH}/usr/lib)
